<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %> 
<%@ taglib uri="/WEB-INF/tld/sys.tld" prefix="sys" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
 <meta name="renderer" content="webkit">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>项目报价方案</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>

<script type="text/javascript">
	var buOrgCd = '${buOrgCd}';
	var grid = null;
	var yesOrNoCdListJSON = [];
	var detailFlag='${detailFlag}';
    <c:if test="${not empty yesOrNoCdListJSON}"> yesOrNoCdListJSON = ${yesOrNoCdListJSON}; </c:if>
	$(function () {
		initGrid();
	});
	
	//初始化列表
	function initGrid(){
		var  flag = true;
		if(detailFlag=="true"){
			flag = false;
		}
		var params = {};
		$("#grid").ligerGrid({
	    	url: '<%=path%>/project/calquatprps/initList.do',
	    	method : 'get',
	    	parms:params,
	        columns: [
	            { display: '方案名称', name: 'prpsCfgNm', minWidth: 140,
	            	render: function (rowdata, rowindex, value, column) { 
	            		var h = '';
	            		    h='<a  href="javascript:detailBtn(';
	                        h+="'"+rowdata.id+"'";
	                        h+=')">'+value+'</a>'
	                        return h;
	            		}	
	            },
	            { display: '合同额', name: 'contAmt', minWidth: 140,render:renderAmt,enabledSort:true},
	            { display: '租赁期数', name: 'lsPd', minWidth: 60 , enabledSort:true},
                { display: '年利率(%)', name: 'annIntRatePct', minWidth: 100},
                { display: '年利率2(%)', name: 'annIntRatePct2', minWidth: 100},
	            { display: '支付方式', name: 'payWayCdNm', minWidth: 100 },
	            { display: '方案产品类型', name: 'prpsTypCdNm', minWidth: 100 },
	            { display: '实际收益率(%)', name: 'irrPct', minWidth: 100},
	            { display: '实际收益率2(%)', name: 'irrPct2', minWidth: 100},
              /*  { display: '产品分类', name: 'prdTypCdNm', minWidth: 100},*/
                { display: '产品收益率(%)', name: 'prdIrrPct', minWidth: 100},
                { display: '数据来源', name: 'dsCdNm', minWidth: 100},
	            { display: '创建时间', name: 'crtTm', minWidth: 60, render:renderDate},
	            {
	                display: '操作',
	                isSort: false,
	                width: 150,
	                render: function (rowdata, rowindex, value){
	                	 var h="";
	                	 if(detailFlag!="true"){
			                        h+='<a class="sq-button-hasicon" href="javascript:modifyBtn(';
			                        h+="'"+rowdata.id+"'";
			                        h+=')"><i class="sqBtnIco_4"></i>修改</a>';
			                        h+='<a class="sq-button-hasicon" href="javascript:removeBtn(';
			                        h+="'"+rowdata.id+"'";
			                        h+=')"><i class="sqBtnIco_4"></i>删除</a>';
	               		 }
	                    return h;
	                }
	            }
	        ],
	        pageSize:100,
	        root:'rows',
	        record:'total',
	        hideLoadButton : true,
	        width: '100%',
	        height:'100%',
	        heightDiff:-2,
	        checkbox:true,
	        allowUnSelectRow: true,
            alternatingRow: true,
	        rownumbers:true,
	        enabledEdit: flag,
	        usePagerOnLessPagesize: true
	    });
		grid = liger.get("grid");
		grid.setHeight(300);
	}
	//格式化为人民币格式
	function renderAmt(rowdata, rowindex, value) {
        var h="￥" + FormatMoney(value)
        return h;
    }
	//格式化时间
	function renderDate(rowdata, index, value){
		var dateStr = "";
		if(null != value&&value!=''){
			var date = new Date(value);
			dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
		}
		return dateStr;
	}
	//添加
	function addBtn(){
		var callback = function(){
			 grid.reload();
		}
        $.ligerDialog.SQopen({title: '选择方案', height: 400,width: 1000, url: '<%=path%>/project/calquatprps/toChooseQuatPrpsListPage.do', isResize: true ,callback:callback});
	}

	//修改
    function modifyBtn(id){
        var callback = function(){
            grid.reload();
        }
        Add_navTab('tab_prj_quat_prps'+id,'修改报价方案','<%=path%>/project/calquatprps/toAddPage.do?id='+id,callback);
    }
	
	//查看
    function detailBtn(id){
        var editFlag = true;
            Add_navTab('tab_prj_quat_prps'+id,'查看报价方案','<%=path%>/project/calquatprps/toAddPage.do?id='+id+'&&detailFlag='+editFlag);
    }

	function iframeResize () {
	    if (parent.mainApp) {
	        parent.mainApp.parentTab.onResize();
	    };
	}
    // 删除报价版方案及明细信息
	function removeBtn(id){
		var _ids = [];
		_ids.push(id);
		$.ligerDialog.confirm(LogUtils.LOG_CMM_DELETE_CONFIRM, function (flag) {
			if(flag == false)return;
			$.ajax({
				type: 'post',
				dataType:'json',
				data:{ids:JSON.stringify(_ids)},
				url: '<%=path%>/project/calquatprps/removeByIds.do',
				success:function(msg){
					 if(msg.success == 1){
						 grid.reload();
					 }else{
						 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
					 }
				}
			});
		});
		
	}

	
</script>

<body class="iframeBody">
	<div class="Wrapper">
      <div id="pageInTab" class="pageInTab">
      <div class="searchArea">
    <form id="searchBar">
       <div class="fieldset1 clearFix">
<div class="btnsBox">
      <span id="addBtn"  onclick="addBtn();"  class="sq-button sq-button-round" >新增</span>
  </div>
  </div>
</form>
</div>
<div id="grid" class="sq-grid"></div>
</div>
		</div>
</body>
</html>